package carRental;

public class JiaoCar extends Car{
    private String type;


    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public JiaoCar(String brand,String type) {
        this.type = type;

    }

    public JiaoCar(String num, String brand, double rent, String type) {
        super(num, brand, rent);
        this.type = type;
    }

    @Override
    public String toString() {
        return "Cars{" + "type='" + type + '\'' + '}';
    }

    //计算小汽车的总租金
    @Override
    public double totalmoney(int days, double rent) {
        if (days>7){
            return days*rent*0.9;
        }else if (days>30){
            return days*rent*0.8;
        }else if (days>150){
            return days*rent*0.7;
        }
        return days*rent;
    }
    //重写equals方法
    @Override
    public boolean equals(Car car) {
        if (car instanceof JiaoCar){
            JiaoCar cars= (JiaoCar) car;
            return this.getType().equals(cars.getType())&&this.getBrand().equals(car.getBrand());
        }
        return false;
    }
}